<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html> 
<head>
<%@ include file="/WEB-INF/jsp/include/easyui.jsp" %>
<%@ include file="/WEB-INF/jsp/include/pForm.jsp" %>
<%@ include file="/WEB-INF/jsp/include/easyui-layui-upload.jsp" %>
<title>合同管理新增页面</title>
<script>

function assistUnitOnchange(newValue, oldValue){
	var len = newValue.length;
	if(len>5){
		$.messager.alert('温馨提醒','分包单位最大不能超过5个！','warning');
		return false ;
	}
	$("input[name=assistUnit]").val(newValue.join(","));
}

$(function(){
	fn.isTab = true;
	fn.resetForm();
	
	var orderId = '${param.orderId}';
	if(orderId){
		$.getJSON('/console/com.fs.jzzn.pojo.Contract/json', {id:orderId,id_searchType: 'eq'} , function(data){
			if(data){
				data = $.extend(data,{ id:'',contractNo:'',attachment:'',url:'',remark:'' ,outContractNo:'',createrId:'',contractName:'',contractLevel: '合同'});
				$('#easyuiForm').form("load",data);
			}
		}); 
	}
	
	/*编号生成*/
	var userDialog = null;
	$("#outContractNo").textbox({    
	    buttonText:'创建',
	    buttonIcon:'icon-reload',
	    iconAlign:'left',
	    onClickButton:function(){
	    	userDialog = $("<div/>").dialog("openWin", { 
     		    title: '内部合同编号创建',   
     		    width:  550,
     		    height: 200,   
     		    href : '/console/autoCno/choosebox',
     		    data: {},
     		    buttons : [
     		        {
		            	   text : "确定", iconCls : "icon-ok", handler : function() {
		            		   var no = userDialog.iframeWindow.choose() || '';
		            		   if(no){
		            			   var temp = no.split("-");
		            			   if(temp.length==4){
		            				   temp = temp[2];
		            				   if(temp=='A'){
		            					   temp = '自营';
		            				   }else if(temp=='B'){
		            					   temp ='合作(内)';
		            				   }else if(temp=='C'){
		            					   temp ='分包';
		            				   }else if(temp=='D'){
		            					   temp ='合作(外)';
		            				   }else{
		            					   temp = '';
		            				   }
		            				   $('#contractType').combobox('select', temp);
		            			   }
			            		   $("#outContractNo").textbox('setText',no);
			            		   $("#outContractNo").textbox('setValue',no);
		            		   }
		            		   userDialog.dialog('close');
		            	   }
     		        },
						{
							text : "关闭", iconCls : "icon-no", handler : function() {
								userDialog.dialog('close');
							}
						}
     		    ]
     		});
     		userDialog.dialog("center");
	    }
	})
	setTimeout(function(){
		$("input[textboxname=remark]").prev().css({"line-height":"60px"});
	},200);
	
	/* fn.onBeforeSubmitForm = function(){
		var contractName = $("#contractName").combobox("getText");
		$("input[name=contractName]").val(contractName);
		
		var contractName = $("#contractTitle").combobox("getText");
		$("input[name=contractTitle]").val(contractName);
	} */
	fn.bindTabButton("#form_butons a");
});
function onOrgNoSelect(record){
	$('input[name=department]').val(record.orgName);	       
}
</script>
</head>
<body>
	<div class="easyui-panel" data-options="fit:true,border:false" style="padding:10px;">
		<div class="easyui-layout" data-options="fit:true">
			<div data-options="region:'center',border:false" style="padding:2px">
				<!-- 替换自动form表单 -->
				<form id="easyuiForm" method="post" action="/console/com.fs.jzzn.pojo.Contract/newAdd"   style="width:750px;"  >
				 <!--类名属性及默认主键id-->
				 <input type="hidden" name="className" value="com.fs.jzzn.pojo.Contract" />
				 <input type="hidden" name="id" value="" />
				 <input type="hidden" name="createrId" value="${SESSION_USER.user.id}" />
				 <input type="hidden"  name="department" value="" />
				 
				<div style="margin-bottom:20px">
					<input class="easyui-textbox easyui-validatebox" name="contractName" style="width:725px;" data-options="label:'合同名称:' ,required:true,validType:'length[0,100]' " />
				 </div>
				 
				 <!-- 
				  <div style="margin-bottom:20px">
				  	<input class="easyui-textbox easyui-validatebox" name="contractTitle" style="width:725px;" data-options="label:'订单名称:' ,required:true,validType:'length[0,100]' " />
				 </div>
				  -->
				 
				  <div style="margin-bottom:20px">
				  	<input class="easyui-textbox easyui-validatebox" name="contractNo" style="width:485px;" data-options="label:'合同编号:',validType:'length[0,100]',required:true,
				  		prompt:'填写合同编号'" />
				  	<input class="easyui-datebox easyui-validatebox" name="signDate" style="width:240px;" data-options="label:'签订日期:',required:true" />
				 </div>
				 
				 <div style="margin-bottom:20px">
				 	<input class="easyui-textbox easyui-validatebox" id="outContractNo" name="outContractNo" style="width:240px;" data-options="label:'内部合同编号:',required:true,validType:['length[0,45]','remote[\'/console/contract/remote\',\'outContractNo\']']"" />
				   	<select class="easyui-combotreegrid" name="orgNo" style="width:240px;" data-options="label:'组织结构:',panelWidth:300,panelWidth:450,required:true,
			           	idField: 'orgNo', 
				   		missingMessage:'必填项',
						treeField: 'orgName',
						sortName:'orgOrder',
						onSelect:function(row){
							$('input[name=department]').val(row.orgName);	    
						},
						sortOrder:'asc',
			            url:'/console/com.fs.base.pojo.Org/list', 
			            queryParams:{isTreeGrid:'true', treeId:'id', treePid:'parentId' },
			            columns:[[    
			                {field:'orgName',			width:190,	title:'组织名称' }
				         	,{field:'orgType',			width:70,	title:'分类' }
				         	,{field:'orgNo',				width:100,	title:'组织编码' }
				         	,{field:'orgLeaderName',	width:70,	title:'负责人'}
			            ]]"></select>
					 <input class="easyui-textbox easyui-validatebox" name="url" style="width:240px;" data-options="label:'云储存:' ,required:true" />
				 </div>
				 
				  <div style="margin-bottom:20px">
				  <input class="easyui-textbox easyui-validatebox" name="partA" style="width:240px;" data-options="label:'合同甲方:',required:true" />
				  <input class="easyui-textbox easyui-validatebox" name="partAuser" style="width:240px;" data-options="label:'甲方经办人:' ,required:true" />
				  <input class="easyui-textbox easyui-validatebox" name="partAphone" style="width:240px;" data-options="label:'甲方电话:',required:true" />
				 </div>
				 
				  <div style="margin-bottom:20px">
				  <input class="easyui-textbox easyui-validatebox" name="partB" style="width:240px;" data-options="label:'合同乙方:',required:true" />
				  <input class="easyui-textbox easyui-validatebox" name="partBuser" style="width:240px;" data-options="label:'乙方经办人:' ,required:true" />
				  <input class="easyui-textbox easyui-validatebox" name="partBphone" style="width:240px;" data-options="label:'乙方电话:' ,required:true" />
				 </div>
				 
				 <div style="margin-bottom:20px">
				 	<select class="easyui-combobox" name="mainUnit" style="width:240px;" data-options="label:'总包单位:' ,required:true" 
						url="/console/combobox?valueField=name&textField=name&modleName=assistUnit&type_searchType=eq" >
				 	</select>
				  	<select class="easyui-combobox" id="assistUnit" style="width:240px;" data-options="label:'分包单位:' ,required:true,multiple:true,onChange:assistUnitOnchange" 
						url="/console/combobox?valueField=name&textField=name&modleName=assistUnit&type_searchType=eq" >
				 	</select>
				 	<!-- 分包单位隐藏域 -->
				 	<input type="hidden" name="assistUnit" />
				 	<input class="easyui-textbox easyui-validatebox" name="payDesc" style="width:240px;" data-options="label:'付款情况:'" />
				 </div>
				  
				 <div style="margin-bottom:20px">
					  	<select id="contractType" class="easyui-combobox" name="contractType" style="width:240px;" data-options="label:'合同类型:' ,required:true" 
							url="/console/combobox?valueField=dicName&textField=dicName&modleName=dictionary&pCode=B6&pCode_searchType=eq" >
					   	</select>
					   	
					   	<select class="easyui-combobox" name="contractLevel"  style="width:240px;" data-options="label:'合同级别:',required:true">
					   		<option value="合同"  selected="selected">合同</option>
					   		<option value="框架协议">框架协议</option>
					   	</select>
				  		<input class="easyui-textbox easyui-validatebox" name="remark" multiline="true" style="width:240px;height:60px;" data-options="label:'备注:',required:true,validType:'length[0,500]'" />
				 </div>
				 
				 <div style="margin-bottom:20px">
				 	<input class="easyui-layuiupload" name="attachment" style="width:725px;" data-options="label:'附件:',upload:{auto:false,height:250}" />
				 </div>
				</form>
			</div>
			<div data-options="region:'south',split:false,collapsible:false" style="height:40px;">
				<div style="padding:5px 20px;text-align: right;background: #F4F4F4;border-width: 1px;border-style: solid;border-color: #dddddd #95B8E7 #95B8E7 #95B8E7;" id="form_butons">
					<a href="javascript:void(0)" id="f_btn_submit" class="easyui-linkbutton" data-options="iconCls:'icon-edit'"  style="width:80px">提交</a>
					<a href="javascript:void(0)" id="f_btn_close" class="easyui-linkbutton" data-options="iconCls:'icon-no'"  style="width:80px">关闭</a>  
				</div>
			</div>   
		</div>
	</div>
</body>
</html>